<?php
	 $root_dir = realpath(dirname(__FILE__));
    include_once($root_dir."/config/config.php");
    define('APP_DIR',ROOT_DIR."/app/");
    include_once(APP_DIR."/base/defined.php");
    
    require(ROOT_DIR.'/app/base/kernel.php');
    if(!kernel::register_autoload()){
        require(APP_DIR.'/base/autoload.php');
    }

		$db = kernel::database();
		$sql = "select * from sdb_tbdata_product where cid=1512 and id>3444";

		$db_rs = $db->exec($sql);
		$rs = $db_rs['rs'];

		$i = 0;
		$base_url = 'http://s.etao.com';
        $http = kernel::single('base_httpclient');
		while($product = mysql_fetch_assoc($rs)){

			$props_str = $product['props_str'];
			$props_str = substr($props_str,strrpos($props_str,':')+1);
			$props_str = trim($props_str);
			if(!$props_str) continue;
			$html = $http->get('http://s.etao.com/search?q='.urlencode($props_str).'&style=grid&s=0');
			if(!$html) continue;
			$sql = "insert into sdb_tbdata_hellomoto(content,product_id,keyword)values('".base64_encode($html)."',".$product['id'].",'".$props_str."')";

			$db->exec($sql);
		}